<template>
	<view class="content">
		<view class="tabber_box flexs1">
			<view class="tabber_item" @click='clickbtn(1)' :class="{'chooseactive':typeindex==1}">
				<view>课程</view>
				<view class="title_line" v-show="typeindex==1"></view>
			</view>
			<view class="tabber_item" @click='clickbtn(2)' :class="{'chooseactive':typeindex==2}">
				<view>试卷</view>
				<view class="title_line" v-show="typeindex==2"></view>
			</view>
			<view class="tabber_item" @click='clickbtn(3)' :class="{'chooseactive':typeindex==3}">
				<view>试题</view>
				<view class="title_line" v-show="typeindex==3"></view>
			</view>
			<view class="tabber_item" @click='clickbtn(4)' :class="{'chooseactive':typeindex==4}">
				<view>资讯</view>
				<view class="title_line" v-show="typeindex==4"></view>
			</view>
			<view class="tabber_item" @click='clickbtn(5)' :class="{'chooseactive':typeindex==5}">
				<view>公司</view>
				<view class="title_line" v-show="typeindex==5"></view>
			</view>
		</view>
		<view class="list_box">
			<!-- 课程 -->
			<block v-if="typeindex==1">
				<view class="none_msg" v-if="CourseList.length==0">
					<image src="../../static/image/wdsc_img_k@2x.png" mode=""></image>
					<view class="none_title">暂无信息</view>
				</view>
				<view class="list_item" v-for="(item,index) in CourseList" :key="index" v-else>
					<view class="list_content" @click="goKeCheng(item.c_id)">
						<view class="list_content_l">
							<image :src="picture.getImgUrl(item.curriculum.image)" mode="aspectFit"></image>
						</view>
						<view class="list_content_r">
							<view class="list_content_title">{{item.curriculum.name}}</view>
							<view class="list_content_time">收藏时间：{{item.createtime}}</view>
						</view>
					</view>
					<view class="list_btm">
						<view class="list_btn1" @click="CancelCourse(item.c_id)">取消收藏</view>
					</view>
				</view>
			</block>
			<!-- 试卷 -->
			<block v-if="typeindex==2">
				<view class="none_msg" v-if="TestList.length==0">
					<image src="../../static/image/wdsc_img_k@2x.png" mode=""></image>
					<view class="none_title">暂无信息</view>
				</view>
				<view class="list_item1" v-for="(item,index) in TestList" :key="index" v-else>
					<view class="list_content1" @click="goSiJuan(item.q_id)">
						<view class="list_content_title">{{item.question.name}}</view>
						<view class="list_content_time">收藏时间：{{item.createtime}}</view>
					</view>
					<view class="list_btm">
						<view class="list_btn1" @click="CancelTest(item.q_id)">取消收藏</view>
					</view>
				</view>
			</block>
			<!-- 试题 -->
			<block v-if="typeindex==3">
				<view class="none_msg" v-if="AnswerList.length==0">
					<image src="../../static/image/wdsc_img_k@2x.png" mode=""></image>
					<view class="none_title">暂无信息</view>
				</view>
				<view class="test_item" v-for="(item,index) in AnswerList" :key="index" v-else>
					<view class="test_top">
						<view class="test_top_l">题目：{{item.questionitem.name}}</view>
						<view class="test_top_r">
							<image src="../../static/image/ly_ico_sc@2x.png" mode="" @click="CancelAnswer(item.qi_id)">
							</image>
						</view>
					</view>
					<view class="test_sel_item" v-for="(items,indexs) in item.answer_list" :key="indexs">
						<view class="test_sel_index" :class="{'testactive':item.questionitem.true_answer==indexs}">
							{{indexs}}</view>
						<view class="test_sel_con">{{items}}</view>
					</view>
					<view class="test_btm">收藏时间：{{item.createtime | filterFunc}}</view>
				</view>

			</block>
			<!-- 资讯 -->
			<block v-if="typeindex==4">
				<view class="none_msg" v-if="newsList.length==0">
					<image src="../../static/image/wdsc_img_k@2x.png" mode=""></image>
					<view class="none_title">暂无信息</view>
				</view>
				<view class="news_item" v-for="(item,index) in newsList" :key="index" v-else>
					<view class="news_top" @click="goNaws(item.content_id)">
						<view class="list_content_l">
							<image :src="picture.getImgUrl(item.image)" mode="aspectFit"></image>
						</view>
						<view class="news_top_r">
							<view class="news_title">{{item.name}}</view>
							<view class="list_news_info">
								<view class="list_content_time">收藏时间：{{item.createtime}}</view>
								<view class="list_seenum">
									<image src="../../static/image/zcht_ico_yd_nor@2x.png" mode=""></image>599
								</view>
							</view>
						</view>
					</view>
					<view class="list_btm">
						<view class="list_btn1" @click="cancelNews(item.content_id)">取消收藏</view>
					</view>
				</view>
			</block>
			<!-- 公司 -->
			<block v-if="typeindex==5">
				<view class="none_msg" v-if="ComList.length==0">
					<image src="../../static/image/wdsc_img_k@2x.png" mode=""></image>
					<view class="none_title">暂无信息</view>
				</view>
				<view class="list_item" v-for="(item,index) in ComList" :key="index" v-else>
					<view class="list_content" @click="goCom(item.c_id)">
						<view class="list_content_l">
							<image :src="urls+item.company.image" mode="aspectFit"></image>
						</view>
						<view class="list_content_r">
							<view class="list_content_title">{{item.company.name}}</view>
							<view class="list_content_time">收藏时间：{{item.createtime}}</view>
						</view>
					</view>
					<view class="list_btm">
						<view class="list_btn1" @click="CancelCom(item.c_id)">取消收藏</view>
					</view>
				</view>
			</block>
		</view>
		<!-- 取消弹窗 -->
		<view class="cu-modal" :class="modalName1=='Modal1'?'show':''">
			<view class="cu-dialog">
				<view class="cu_title">
					<view></view>
					<view class="text-bold cu-item-title1">提示</view>
					<view class="action1" @click="hideModal1">
						<image src="../../static/image/ico_ts_gb@2x.png" mode=""></image>
					</view>
				</view>
				<view class="padding_xl">
					<view class="cu_tip">您确定取消该订单吗？</view>
				</view>
				<view class="button">
					<view class="cu_btn">确定</view>
				</view>
			</view>
		</view>
		<!-- 删除弹窗 -->
		<view class="cu-modal" :class="modalName=='Modal'?'show':''">
			<view class="cu-dialog">
				<view class="cu_title">
					<view></view>
					<view class="text-bold cu-item-title1">提示</view>
					<view class="action1" @click="hideModal">
						<image src="../../static/image/ico_ts_gb@2x.png" mode=""></image>
					</view>
				</view>
				<view class="padding_xl">
					<view class="cu_tip">您确定删除该订单吗？</view>
				</view>
				<view class="button">
					<view class="cu_btn">确定</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		CMYcollect,
		cancelcollect,
		collectList,
		collect,
		Ecollectlist,
		Ecollect,
		getinfocollect,
		Recruitinformation,
		mycollect,
		cancelformation
	} from '@/api/personal.js'
	export default {
		data() {
			return {
				typeindex: 1,
				modalName1: null,
				product_star: 5,
				modalName: null,
				seltype: 1,
				testindex: 0,
				newsList: [],
				ComList: [],
				CourseList: [],
				TestList: [],
				AnswerList: [],
				answlist: []
			}
		},
		onLoad() {
			this.getCourseList()
		},
		filters: {
			filterFunc: function(value) {
				if (value && value.length > 11) {
					return value.substring(0, 11) + ' ';
				}
				return value;
			}
		},
		methods: {
			clickbtn(val) {
				this.typeindex = val
				if (this.typeindex == 2) {
					this.getTestList()
				} else if (this.typeindex == 3) {
					this.getAnswerList()
				} else if (this.typeindex == 4) {
					this.getNewsList()
				} else if (this.typeindex == 5) {
					this.getComList()
				}
			},
			chooseTest(val) {
				this.testindex = val
			},
			showModal1(e) {
				this.modalName1 = e.currentTarget.dataset.target
			},
			hideModal1(e) {
				this.modalName1 = null
			},
			showModal(e) {
				this.modalName = e.currentTarget.dataset.target
			},
			hideModal(e) {
				this.modalName = null
			},
			// 课程评价
			chooseType(val) {
				this.seltype = val
			},
			goPay() {
				uni.navigateTo({
				 url: '../payment/payment'
				})
			},
			// 课程收藏
			getCourseList() {
				var obj = {};
				CMYcollect(obj).then(res => {
					if (res.code == 1) {
						this.CourseList = res.data.data
					}
				});
			},
			// 取消课程收藏
			CancelCourse(id) {
				var obj = {
					c_id: id
				};
				cancelcollect(obj).then(res => {
					if (res.code == 1) {
						this.$msg(res.msg)
						this.getCourseList()
					}
				});
				
			},
			// 试卷收藏
			getTestList() {
				var obj = {};
				collectList(obj).then(res => {
					if (res.code == 1) {
						this.TestList = res.data.data
					}
				});
			},
			CancelTest(qbid) {
				var obj = {
					qb_id: qbid
				};
				collect(obj).then(res => {
					if (res.code == 1) {
						this.$msg(res.msg)
						this.getTestList()
					}
				});
			},
			// 试题收藏
			getAnswerList() {
				var obj = {};
				Ecollectlist(obj).then(res => {
					if (res.code == 1) {
						this.AnswerList = res.data.data
					}
				})
			},
			CancelAnswer(id) {
				var obj = {
					qi_id: id
				};
				Ecollect(obj).then(res => {
					if (res.code == 1) {
						this.$msg(res.msg)
						this.getAnswerList()
					}
				});
			},
			// 咨讯收藏
			getNewsList() {
				var obj = {

				};
				getinfocollect(obj).then(res => {
					if (res.code == 1) {
						this.newsList = res.data.data
					}
				});
			},
			// 咨讯--取消收藏
			cancelNews(id) {
				var obj = {
					info_id: id
				};
				Recruitinformation(obj).then(res => {
					if (res.code == 1) {
						this.$msg(res.msg)
						this.getNewsList()
					}
				});
			},
			// 公司收藏
			getComList() {
				var obj = {

				};
				mycollect(obj).then(res => {
					if (res.code == 1) {
						this.ComList = res.data.data
					}
				});
			},
			// 取消公司收藏
			CancelCom(id) {
				var obj = {
					c_id: id
				};
				cancelformation(obj).then(res => {
					if (res.code == 1) {
						this.$msg(res.msg)
						this.getComList()
					}
				});
			},
			// 课程跳转
			goKeCheng(id) {
				uni.navigateTo({
					url: '../data/kecheng?id=' + id
				})
			},
			// 试卷跳转
			goSiJuan(id) {
				uni.navigateTo({
					url: '../Brush/testDetL?id=' + id
				})
			},
			// 收藏跳转
			goNaws(id) {
				uni.navigateTo({
					url: '../news/news_det?id=' + id
				})
			},
			// 公司跳转
			goCom(id) {
				uni.navigateTo({
					url: '../Kaoq/Famous_Det?id=' + id
				})
			}

		}
	}
</script>

<style>
	.content {
		width: 100vw;
		height: 100vh;
		overflow: hidden;
	}

	.tabber_box {
		width: 100%;
		height: 80rpx;
		/* margin: auto; */
		background-color: #FFFFFF;
		/* s */
		/* padding-left: 20rpx; */
		position: fixed;
		top: 85rpx;
		/* #ifdef APP-PLUS */
		top: 0;
		/* #endif */
		z-index: 10;
	}

	.tabber_item {
		width: 20%;
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #666666;
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;
		flex-shrink: 0;
	}

	.chooseactive {
		width: 20%;
		font-size: 32rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #333333;
	}

	.title_line {
		width: 60rpx;
		height: 4rpx;
		background: #FFDD47;
		border-radius: 2rpx;
		margin-top: 5rpx;
	}

	.list_box {
		width: 100%;
		/* height: auto; */
		/* #ifdef APP-PLUS */
		height: 100%;
		/* #endif */
		height: calc(100% - 100rpx);
		margin-top: 80rpx;
		padding-bottom: 30rpx;
		overflow-y: auto;
	}

	.list_item {
		width: 100%;
		height: 290rpx;
		background-color: #FFFFFF;
		padding: 0rpx 30rpx;
		margin-top: 20rpx;
	}

	.list_item1 {
		width: 100%;
		height: 240rpx;
		background-color: #FFFFFF;
		padding: 0rpx 30rpx;
		margin-top: 20rpx;
	}

	.list_top {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.list_top_l {
		font-size: 24rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #999999;
	}

	.list_top_r {
		font-size: 24rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #FF3B30;
	}

	.list_content {
		width: 100%;
		height: 190rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		border-bottom: 1rpx solid #F5F5F5;
	}

	.list_content1 {
		width: 100%;
		height: 140rpx;
		padding-top: 30rpx;
		border-bottom: 1rpx solid #F5F5F5;
	}

	.list_content_l image {
		width: 196rpx;
		height: 130rpx;
		background: #F7F5F6;
		border-radius: 10rpx;
	}

	.list_content_r {
		width: 68%;
		height: 130rpx;
	}

	.list_content_title {
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #333333;
	}

	.list_content_money {
		font-size: 24rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #FF3B30;
	}

	.list_content_time {
		font-size: 24rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #999999;
		margin-top: 10rpx;
	}

	.list_btm {
		width: 100%;
		height: 100rpx;
		display: flex;
		justify-content: flex-end;
		align-items: center;
	}

	.list_btn {
		width: 120rpx;
		height: 40rpx;
		border: 1rpx solid #CCCCCC;
		border-radius: 4rpx;
		font-size: 24rpx;
		font-weight: 500;
		color: #333333;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.list_btn1 {
		width: 120rpx;
		height: 40rpx;
		background: #FFDD47;
		border-radius: 4rpx;
		font-size: 24rpx;
		font-weight: 500;
		color: #333333;
		display: flex;
		justify-content: center;
		align-items: center;
		margin-left: 40rpx;
	}

	/* 试题 */
	.test_item {
		width: 100%;
		height: auto;
		padding: 30rpx 30rpx;
		background-color: #FFFFFF;
		margin-bottom: 20rpx;
	}

	.test_top_r image {
		width: 26rpx;
		height: 26rpx;
	}

	.test_top {
		width: 100%;
		height: auto;
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 20rpx;
	}

	.test_top_l {
		width: 80%;
		height: auto;
	}

	.test_sel_item {
		width: 100%;
		height: 70rpx;
		display: flex;
		align-items: center;
	}

	.test_sel_index {
		width: 36rpx;
		height: 36rpx;
		border: 1rpx solid #CCCCCC;
		border-radius: 50%;
		font-size: 22rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #333333;
		display: flex;
		justify-content: center;
		align-items: center;
		margin-right: 40rpx;
	}

	.testactive {
		width: 36rpx;
		height: 36rpx;
		border: none !important;
		background: #FFDD47;
		border-radius: 50%;
		font-size: 22rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #333333;
		display: flex;
		justify-content: center;
		align-items: center;
		margin-right: 40rpx;
	}

	.test_btm {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: flex-end;
		font-size: 24rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #999999;
	}

	/* 咨讯 */
	.news_item {
		width: 100%;
		height: 290rpx;
		margin-top: 20rpx;
		background-color: #FFFFFF;
		padding: 0 30rpx;
	}

	.news_top {
		width: 100%;
		height: 190rpx;
		display: flex;
		justify-content: flex-start;
		align-items: center;
	}

	.list_seenum image {
		width: 27rpx;
		height: 26rpx;
		margin-right: 10rpx;
	}

	.news_top_r {
		height: 100%;
		width: 68%;
		margin-left: 20rpx;
		padding-top: 30rpx;
		border-bottom: 1rpx solid #F5F5F5;
		display: flex;
		justify-content: space-between;
		align-items: flex-start;
		flex-direction: column;
	}

	.list_news_info {
		display: flex;
		justify-content: space-between;
		align-items: center;
		width: 100%;
		margin-bottom: 35rpx;
	}

	/* 企业评价弹窗 */
	.cu-dialog {
		width: 570rpx;
		height: auto;
		background: #FFFFFF;
		border-radius: 10rpx;
	}

	.cu-item-title {
		font-size: 32rpx;
	}

	.cu-item-title1 {
		width: 100%;
		font-size: 32rpx;
		height: 100rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.action1 image {
		width: 29rpx;
		height: 29rpx;

	}

	.cu_title {
		width: 100%;
		height: 80rpx;
		padding: 0rpx 20rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		background: #F5F5F5;

	}

	.button {
		width: 100%;
		height: 100rpx;
		background-color: #FFFFFF;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.cu_btn {
		width: 250rpx;
		height: 60rpx;
		background: #FFDD47;
		border-radius: 6rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.padding_xl {
		width: 100%;
		height: 120rpx;
		display: flex;
		align-items: center;
		flex-direction: column;
		justify-content: center;
	}

	.cu_start_box {
		width: 100%;
		height: 90rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.cu_start_box image {
		width: 39rpx;
		height: 36rpx;
		margin-right: 10rpx;
	}

	.cu_text_area {
		width: 509rpx;
		height: 140rpx;
		background: #F2F2F2;
		padding: 20rpx 20rpx;
	}

	.text_area_class {
		width: 100%;
		height: 100%;
		text-align: left;
		font-size: 26rpx;
	}

	.input_class {
		font-size: 26rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #999999;
	}

	.cu_close {
		width: 60rpx;
		height: 60rpx;
		position: absolute;
		bottom: 25%;
		right: 45%;
	}

	/* 暂无消息 */
	.none_msg {
		width: 100%;
		height: auto;
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;
		margin-top: 300rpx;
	}

	.none_msg image {
		width: 354rpx;
		height: 253rpx;
	}

	.none_title {
		font-size: 26rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #666666;
		margin-top: 40rpx;
	}
</style>
